
from flask import Flask, render_template, request, send_file, send_from_directory
from docx import Document

from source.upload import upload_files

app = Flask(__name__)
file_path_root = "H:\\"  # windows环境使用


@app.route("/", methods=["GET", "POST"])
def home():
    return render_template("index.html")


@app.route('/upload', methods=['GET', 'POST'])
def upload():
    if request.method == "POST":
        filename = upload_files()
        return render_template('index.html', download_url=filename)

    return render_template("index.html")

@app.route('/download/<filename>', methods=['GET'])
def download(filename):
    directory = file_path_root
    return send_from_directory(directory, filename, as_attachment=True)



if __name__ == '__main__':
    app.run()
